//在listen-radio.js中调用radio.js
var Radio = require("./radio.js");

var inforObj = {"radioName":"音频"};
var radio = new Radio(inforObj);

radio.on("start", ()=>{
    console.log(radio.radioName + " started");
})

radio.on("stop", ()=>{  //如果不是箭头函数而是function(){}则里面不是radio.radioName,而是this
    console.log(radio.radioName + " stoped");
    // console.log(radio); radio是一个对象
})
/* ↑ 相当于 ↓
radio.on("stop", function(){
    console.log(this.radioName + " stoped");
})
*/


setTimeout(()=>{
    radio.emit("start");
},1000);

setTimeout(()=>{
    radio.emit("stop");
},3000);